<template>
  <div class="content-block service-block">
    <div class="service-block">
      <div class="block-line"></div>
      <p class="service-info-title">{{ item.title }}</p>
      <div class="service-list">
        <div class="message-wrapper" v-for="(detail, index) in item.columnsDetails" :key="index"
             @click="handleToPractice(detail)">
          <svg class="icon-third" aria-hidden="true" style="font-size: 20px">
            <use :xlink:href=detail.image></use>
          </svg>
          <div class="message-content-box">
            <div class="message-title ">{{ detail.title }}</div>
            <div class="message-content message-odd">{{ detail.description }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { useRouter } from "vue-router";

const router = useRouter();
const props = defineProps({
  item: {
    type: Object
  },
  repositoryId: {
    type: String
  }
});

function handleToPractice(record) {
  if (record && record.num == 0) {
    return;
  }
  let query = {
    mode: props.item?.mode,
    questionType: record.type
  };
  router.push({ path: `/practice/onlinePractice/${props.repositoryId}`, query: query });
}
</script>
<style lang="less" scoped>
.service-block {
  width: 100%;

  .service-block {
    width: 100%;
    overflow: hidden;
    margin: 0 auto;
    text-align: center;
  }

  .block-line {
    margin: 0 auto 12px;
    width: 24px;
    height: 4px;
    background-color: #3370ff;
    border-radius: 100px;
  }

  .service-info-title {
    font-size: 22px;
    position: relative;
    bottom: 2px;
  }

  .service-info-subtitle {
    font-size: 16px;
    line-height: 1.5;
    color: #646a73;
    margin-top: 30px;
  }

  .message-wrapper {
    display: flex;
    box-sizing: border-box;
    width: 25%;
    justify-content: center;
    align-items: center;
  }

  .message-icon {
    display: inline-block;
    flex-shrink: 0;
    width: 80px;
    height: 80px;
  }

  .message-content-box {
    margin-left: 20px;
  }

  .message-title {
    display: inline-block;
    font-size: 18px;
  }

  .message-content {
    margin-top: 10px;
    color: #646a73;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.79;
    letter-spacing: .3px;
  }

  .service-list {
    display: flex;
    flex-flow: wrap;
    text-align: left;
  }
}
</style>
